home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / T / Thinkcup.cpt / Documentation Update / THINK C 4.0 Doc Update
Encoding:
Text File  |  1990-03-15  |  8.9 KB  |  270 lines  |  [TEXT/KAHL]

  1. THINK C 4.0 ERRATA
  2. ==================
  3. Copyright © 1990 Symantec Corporation. All Rights Reserved.
  4.  
  5. This document corrects several known errors in the documentation for THINK C
  6. 4.0. It has three parts:
  7.  
  8.    • QUESTIONS AND ANSWERS answers several questions users asked about 
  9.      the Standard Library Reference.
  10.  
  11.    • CORRECTIONS corrects typos and other errors in the THINK C 4.0
  12.      documentation, chapter by chapter. 
  13.  
  14.    • NEW FUNCTION DESCRIPTIONS documents some functions that were left
  15.      out of the Standard Library Reference: cecho2printer(), gets(), 
  16.      sin(), sinh(), and sqrt().
  17.  
  18. QUESTIONS AND ANSWERS
  19. =====================
  20. This section several questions users asked about the Standard Library
  21. Reference. The questions are about using the console package, reading from
  22. stdio, and reading to and writing from text files.
  23.  
  24. • WHERE IS THE CONSOLE LIBRARY?
  25.  
  26. There is no console library. That’s an error in the manual. All the functions
  27. described in Chapter 4 of the Standard Libraries Reference are in the ANSI
  28. library. To use these functions in your program, add the ANSI library in your
  29. project and #include console.h in your files. You do not need to add a console
  30. library.
  31.  
  32. • HOW DO I USE THE CONSOLE FUNCTIONS CSETMODE() AND CGOTOXY() WITH A CONSOLE
  33.   WINDOW?
  34.  
  35. Before calling csetmode() or cgotoxy(), call printf("\n"). The functions
  36. csetmode() and cgotoxy() use the file pointer stdout but don’t initialize it.
  37. The function printf() initializes stdout (and stdin and stderr, too) to be the
  38. console window. 
  39.  
  40. • HOW DO I GENERATE THE END-OF-FILE (EOF) CHARACTER?
  41.  
  42. To generate the end-of-file character when a program is reading from stdio,
  43. press Control-D.
  44.  
  45. • WHY DON’T I GET WHAT I EXPECT WHEN I READ FROM OR WRITE TO TEXT FILES?
  46.  
  47. When you write to a text file, '\r' (a carriage return or 0x0D) is converted
  48. to '\n' (a line feed or 0x0A). When you read from a text file, '\n' is
  49. converted to '\r'. 
  50.  
  51.      NOTE: This conversion isn’t performed with binary files. To open a
  52.      file as a binary file, use the function fopen() and append the
  53.      character 'b' to the argument type.
  54.  
  55. For example, this statement:
  56.  
  57.      fputc('\r', f);
  58.  
  59. writes the character '\n' to the file f. 
  60.  
  61. If the file f contains "hello\n", this statement:
  62.  
  63.      fgets(s, 80, f);
  64.  
  65. puts the string "hello\r" into the variable s.
  66.  
  67. CORRECTIONS
  68. ===========
  69. This section corrects typos, omissions, and other errors in the THINK C 4.0
  70. documentation, chapter by chapter.
  71.  
  72. User’s Manual, Chapter 53, “CWindow”
  73. ------------------------------------
  74.  
  75.    • On page 394, the declaration for IWindow() should be: 
  76.  
  77.        void IWindow( short WINDid, Boolean aFloating, 
  78.                      CDesktop *anEnclosure,
  79.                      CDirector *aSupervisor );
  80.  
  81.      Note that anEnclosure is a pointer to a CDesktop, not a pointer to a
  82.      CView.
  83.  
  84. Standard Libraries Reference, Chapter 2, “ANSI Header Files”
  85. ------------------------------------------------------------
  86.  
  87.    • In the list of macros for <float.h> on page 7, the values of DBL_MIN and
  88.      LDBL_MIN should be 1.0E-4926, not 1.0E-4915.
  89.  
  90.    • In the list of macros for <stdlib.h> on page 19, the value of RAND_MAX
  91.      should be 32767, not 3267.
  92.  
  93.    • In the list of functions for <string.h> on page 20 , strcfrm() should
  94.      be strxfrm().
  95.  
  96.    • In the list of types in <time.h> on page 21 , tm is not described. It is
  97.      a structure for broken-down time and is defined like this:
  98.  
  99.        struct tm {
  100.          int tm_sec;   /* seconds after the minute  */
  101.          int tm_min;   /* minutes after the hour    */
  102.          int tm_hour;  /* hours since midnight      */
  103.          int tm_mday;  /* day of the month          */
  104.          int tm_mon;   /* months since January      */
  105.          int tm_year;  /* years since 1900          */
  106.          int tm_wday;  /* days since Sunday         */
  107.          int tm_yday;  /* days since January 1      */
  108.          int tm_isdst; /* Daylight Saving Time flag */
  109.        };
  110.  
  111. Standard Libraries Reference, Chapter 3, “ANSI”
  112. -----------------------------------------------
  113.  
  114.    • These functions aren’t documented: gets(), sin(), sinh(), and sqrt()
  115.      They’re described later in this document
  116.  
  117.    • The functions __getc() and __putc() are the same as getc() and putc(),
  118.      except __getc() and __putc() don’t do any error-checking. For more robust
  119.      code, use getc() and putc() whenever possible. The functions  __getc()
  120.      and __putc() are THINK C extensions to the ANSI standard.
  121.  
  122.    • To use abs() on page 29  or labs() on page 82, #include stdlib.h, not
  123.      math.h.
  124.  
  125.    • To use strlen() on page 134, #include string.h, not strings.h.
  126.  
  127. Standard Libraries Reference, Chapter 4, “console”
  128. --------------------------------------------------
  129.  
  130.    • There is no console library. All the functions in this chapter are in the
  131.      ANSI library.
  132.  
  133.    • The function cecho2printer() isn’t documented. It’s described later in
  134.      this document.
  135.  
  136.    • Despite what the manual says on page 166, ccommand() cannot redirect
  137.      stderr.
  138.  
  139.    • On page 168, C_BREAK should be C_CBREAK.
  140.  
  141. Standard Libraries Reference, Chapter 5, “unix”
  142. -----------------------------------------------
  143.  
  144.    • To use open() on page 196, you need to #include fcntl.h in addition to
  145.      unix.h.
  146.  
  147.  
  148. NEW METHODS
  149. ===========
  150. New methods were added to three classes in the Core Classes of the
  151. THINK Class Library.
  152.  
  153. CError
  154. ------
  155. void MissingResources()
  156.     If gError gets a SevereMacError message, and it can’t find the
  157.     STR resource to report a “resource not found” error, SevereMacError()
  158.     sends a MissingResources() message to gError. This method displays
  159.     an error alert without using any resources.
  160.  
  161. CPanorama
  162. ---------
  163. void DoKeyDown(char theChar, Byte keyCode, EventRecord *macEvent)
  164.     This method supports the Home, End, Page Up, and Page Down keys on the
  165.     extended keyboard for all panoramas. The Home key is equivalent to
  166.     scrolling to the top of the panorama; the End key is equivalent to
  167.     scrolling to the bottom of the panorama. The Page Up and Page Down keys
  168.     are equivalent to clicking on the page up and page down regions of the
  169.     vertical scroll bar of the panorama.
  170.  
  171. CPicture
  172. --------
  173. void Dispose()
  174.     This method disposes of the picture stored in the macPicture
  175.     instance variable.
  176.     
  177.  
  178. NEW FUNCTION DESCRIPTIONS
  179. =========================
  180. This section includes documentation for these functions, which were left out
  181. of the Standard Libraries Reference:
  182.  
  183.    • cecho2printer(), from Chapter 4, “console”
  184.    • gets(), from Chapter 3, “ANSI”
  185.    • sin(), from Chapter 3, “ANSI”
  186.    • sinh(), from Chapter 3, “ANSI”
  187.    • sqrt(), from Chapter 3, “ANSI”
  188.  
  189. ______________________________________________________________________________
  190.  
  191.                     cecho2printer
  192.  
  193. LIBRARY             ANSI
  194.  
  195. SYNTAX              #include <console.h>
  196.                     void cecho2printer(FILE *fp);
  197.  
  198. DESCRIPTION         Echo output to the printer selected in the Chooser desk
  199.                     accessory.
  200.  
  201.                     cecho2printer() writes to the printer any complete lines
  202.                     that the program writes to the console fp.
  203.  
  204. ______________________________________________________________________________
  205.  
  206.                     gets
  207.  
  208. LIBRARY             ANSI
  209.  
  210. SYNTAX              #include <stdio.h>
  211.                     char *gets(char *s);
  212.  
  213. DESCRIPTION            gets() reads the next line from stdin into the array s.
  214.                     gets() stops reading after it encounters a new-line or EOF
  215.                     character, replaces the new-line or EOF in s with a NULL
  216.                     character, and returns successful.
  217.  
  218. RETURNS             s, if successful.
  219.  
  220.                     NULL, if failure. If it encounters an EOF and has not read
  221.                     any characters, it doesn’t change the contents of s and
  222.                     sets the EOF error flag in the file descriptor. If a read
  223.                     error occurs, the contents of s are indeterminate.
  224.  
  225. ______________________________________________________________________________
  226.  
  227.                     sin
  228.  
  229. LIBRARY             ANSI
  230.  
  231. SYNTAX              #include <math.h>
  232.                     double sin(double x);
  233.  
  234. DESCRIPTION         sin() computes the sine of the argument x.
  235.  
  236. RETURNS             sin x, in radians.
  237.  
  238. ______________________________________________________________________________
  239.  
  240.                     sinh
  241.  
  242. LIBRARY             ANSI
  243.  
  244. SYNTAX              #include <math.h>
  245.                     double sinh(double x);
  246.  
  247. DESCRIPTION         sinh() computes the hyperbolic sine of the argument x.
  248.  
  249. RETURNS             sinh x, in radians, if successful.
  250.  
  251.                     Infinity, if x greater than HUGE_VAL. It also sets errno
  252.                     to ERANGE.
  253.  
  254. ______________________________________________________________________________
  255.  
  256.                     sqrt
  257.  
  258. LIBRARY             ANSI
  259.  
  260. SYNTAX              #include <math.h>
  261.                     double sqrt(double x);
  262.  
  263. DESCRIPTION         sqrt() computes the square root of the argument x.
  264.  
  265. RETURNS             The square root of x, if successful, 
  266.  
  267.                     0, if x is negative. It also sets errno to EDOM.
  268.  
  269.  
  270.